<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="../../css/demo.css" />
    
    <title>Jslet - DBText</title>
    <script type="text/javascript" data-main="../../config.js" src="../../lib/requirejs/require.min.js"></script>
    <script type="text/javascript">
	    require(['dbcontrol/form/a-dbtext']);
    </script>
</head>
<body>
    <div class="demo-header">
    <h4 id="top">Jslet - DBText</h4>
	</div>
	<hr />
	<div class="demo-desc">
	<p>DBText可以输入各种类型的数据，如字符型，数字型，日期型，甚至带下拉选择的数据。</p>
	</div>

	<div data-jslet="type: 'DBTable', dataset: 'employee'" style="margin-bottom: 10px"></div>
	
	<div class="container-fluid">
	<div class="form-horizontal">
	<div class="form-group form-group-sm" style="vertical-align: middle">
	<div class="col-sm-2">
		<label>姓名（字符型）</label>
	</div>
	<div class="col-sm-2">
		<input data-jslet="type: 'DBText', dataset: 'employee', field: 'name'"></input>
	</div>
	<div class="col-sm-2">
		<label>工资（数字型）</label>
	</div>
	<div class="col-sm-2">
		<input data-jslet="type: 'DBText', dataset: 'employee', field: 'salary'"></input>
	</div>
	<div class="col-sm-2">
		<label>生日（实际为日期控件）</label>
	</div>
	<div class="col-sm-2">
		<input data-jslet="type: 'DBText', dataset: 'employee', field: 'birthday'"></input>
	</div>
	</div>
	<div class="form-group form-group-sm" style="vertical-align: middle">
	<div class="col-sm-2">
		<label>部门（下拉选择数据）</label>
	</div>
	<div class="col-sm-2">
		<input data-jslet="type: 'DBText', dataset: 'employee', field: 'department'"></input>输入：00， 01，02试试
	</div>

	</div>
	<div class="form-group form-group-sm" style="vertical-align: middle">
	<div class="col-sm-2">
		<label>对值进行选择和插入操作</label>
	</div>
	<div class="col-sm-2">
		<input id="txtName" data-jslet="type: 'DBText', dataset: 'employee', field: 'name'"></input>
		<button id="btnInsertChar" class="btn btn-default btn-sm">插入字符“("</button>
	</div>

	</div>
	</div>
	</div>
	
	
	<hr />
	<h4>源码</h4>
	<h5>HTML</h5>
    <pre class="prettyprint linenums"><code>
    //姓名（字符型）
    &lt;input data-jslet="type: 'DBText', dataset: 'employee', field: 'name'">&lt;/input>
    
    //工资（数字型）
    &lt;input data-jslet="type: 'DBText', dataset: 'employee', field: 'salary'">&lt;/input>
    
    //生日（实际为日期控件）
    &lt;input data-jslet="type: 'DBText', dataset: 'employee', field: 'birthday'">&lt;/input>
    
    //部门（下拉选择数据）
    &lt;input data-jslet="type: 'DBText', dataset: 'employee', field: 'department'">&lt;/input>
    
	</code></pre>
    
	<h5>JavaScript</h5>
    <pre class="prettyprint linenums"><code>
	//datasetMetaStore定义在公共js:common/datasetmetastore.js中
	//将数据集定义信息仓库加到datasetFactory中，创建Dataset时会仓库里去定义信息
	jslet.data.datasetFactory.addMetaStore(window.datasetMetaStore);
	//通过工厂方法，可以自动创建主数据集及相关的数据集
    jslet.data.datasetFactory.createDataset('employee').done(function() {
    	jslet.data.getDataset('employee').query();
    	jslet.ui.install();
    });
    
    //插入字符,可以通过代码插入字符到当前光标处
    $('#btnInsertChar').click(function() {
    	jslet('#txtName').inputText('(');
    });
	</code></pre>

    <script type="text/javascript">
       window.LOADER_BASE_URL = "../../lib/prettify";
    </script>
    <script type="text/javascript" src="../../lib/prettify/run_prettify.js"></script>
		
</body>
</html>
